home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
5685
/
5685.xpi
/
chrome
/
vodpod.jar
/
content
/
overlay.js
< prev
next >
Wrap
Text File
|
2008-06-27
|
5KB
|
104 lines
var vodpod_button = {
prefix: 'savevideo@vodpod.com',
button_id: 'vodpod-toolbar-button',
loaded: false,
onLoad: function() {
try {
// initialization code
if (!this.loaded) {
this.loaded = true;
this.strings = document.getElementById("vodpod-strings");
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
// The 'target' is the target for the button. This could be a dedicated site (like wordpress.com)
// or could be generic.
this.target = prefs.getCharPref("extensions." + this.prefix + ".target");
setTimeout("VodpodDelayedInit('" + this.prefix + "','" + this.button_id + "');", 0);
}
}catch(e) {alert(e);}
},
onMenuItemCommand: function(e) {
try {
content.window.stop();
//var script = content.document.createElement('script');
//var src = 'http://www.vodpod.com/javascripts/bookmarklet.js?' + parseInt(Math.random()*9999);
//script.src = src;
//content.document.body.appendChild(script);
vodpod.share_video(content.document, this.target, content.window);
} catch(e) {
alert(e);
}
},
onToolbarButtonCommand: function(e) {
// just reuse the function above. you can change this, obviously!
vodpod_button.onMenuItemCommand(e);
},
search_dialog: function(e) {
window.openDialog("chrome://vodpod/content/search_popup.xul", 'video_search','chrome=yes,resizable=yes,centerscreen,width=400,height=140');
},
go_help: function(e) {
var help_url = "http://www.vodpod.com/vpbutton/help";
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
try {
help_url = prefs.getCharPref("extensions." + prefix + ".help");
} catch(e) {}
var tabBrowser = top.getBrowser();
if (tabBrowser) {
tabBrowser.loadOneTab(help_url, null, null, null, false, false);
}
}
};
// Our init logic is to always install the button if it's missing, but only show the help
// page if the user has never installed the extension. Once the user has seen the help page,
// then we write a preference so we don't show it again. However, the way firefox works is that
// that preference will persist even if the user removes our extension. This gives these results:
// --Help page only shown after first ever install of the extension
// --Toolbar button will always be added to the toolbar on Firefox startup
// --If user just removes button from toolbar, it will be re-added next time. They have to remove
// the extension to get rid of it permanently.
function VodpodDelayedInit(prefix, button_id) {
VodpodAddToolbarItem(button_id);
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
if (!prefs.prefHasUserValue("extensions." + prefix + ".installed")) {
prefs.setBoolPref("extensions." + prefix + ".installed", true);
var help_url = "http://www.vodpod.com/vpbutton/start";
try {
help_url = prefs.getCharPref("extensions." + prefix + ".start");
} catch(e) {}
var tabBrowser = top.getBrowser();
if (tabBrowser) {
tabBrowser.loadOneTab(help_url, null, null, null, false, false);
}
}
}
function VodpodAddToolbarItem(button_id)
{
var firefoxnav = document.getElementById("navigation-toolbar") || document.getElementById("nav-bar"); // use "nav-bar" in Firefox 2 and earlier
//alert("nav toolbar: " + firefoxnav);
var curSet = firefoxnav.currentSet;
if (curSet.indexOf(button_id) == -1)
{
var set;
// Place the button before the urlbar
if (curSet.indexOf("urlbar-container") != -1)
set = curSet.replace(/urlbar-container/, button_id + ",urlbar-container");
else // at the end
set = firefoxnav.currentSet + "," + button_id;
firefoxnav.setAttribute("currentset", set);
firefoxnav.currentSet = set;
document.persist("nav-bar", "currentset"); // Firefox 2
document.persist("navigation-toolbar", "currentset"); // Firefox 3 and later
// If you don't do the following call, funny things happen
try {
//alert("CustomizeDone call");
BrowserToolboxCustomizeDone(true);
}
catch (e) { }
}
}
window.addEventListener("load", function(e) { vodpod_button.onLoad(e); }, false);